using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System;
using System.Reflection;

namespace Polymod
{
    public sealed class Formula<T, R> : IFormula
    {
        private string _name;
        private Expression<Func<T, R>> _expression;

        /// <summary>
        /// Gets Name
        /// </summary>
        public string Name
        {
            get { return _name; }
        }

        /// <summary>
        /// Gets Expression
        /// </summary>
        public Expression<Func<T, R>> Expression
        {
            get { return _expression; }
        }

        internal Formula(string name, Expression<Func<T, R>> expression)
        {
            if (expression == null) throw new System.ArgumentNullException("expression");
            if (name == null) throw new System.ArgumentNullException("propertyName");
            _name = name;
            _expression = expression;
        }

        public R Evaluate()
        {
            return default(R);
        }

        public Func<T, R> AsFunc()
        {
            return null;
        }
        //TODO: Use those instead or AsExpression and AsFunc? (or have both)
        //public static implicit operator Expression<Func<T, R>>(Formula<T, R> formula)
        //{
        //    return null;
        //}

        //public static implicit operator Func<T, R>(Formula<T, R> formula)
        //{
        //    return null;
        //}

        LambdaExpression IFormula.Expression
        {
            get { return this.Expression; }
        }
    }
}
